package com.example.natatorium_management.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.natatorium_management.entity.Order;
import com.example.natatorium_management.entity.OrderGood;
import com.example.natatorium_management.mapper.OrderGoodMapper;
import com.example.natatorium_management.result.restful.R;
import com.example.natatorium_management.result.restful.ResponseEunm;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
@Service
public class OrderGoodServiceImpl extends ServiceImpl<OrderGoodMapper,OrderGood> {

    public R<OrderGood> addGoodInOrder(List<Long> goodIds,Long orderId){
        List list = new ArrayList<>();
        for (int i = 0; i < goodIds.size(); i++) {
            OrderGood orderGood = new OrderGood(null,orderId,goodIds.get(i));
            list.add(orderGood);
        }
        super.saveBatch(list);
        return new R<>(ResponseEunm.SUCCESS,null);
    }
}
